package com.ccb.jyzx.expand.ouapi.controller;

import com.ccb.jyzx.expand.ouapi.beans.OrganiztionInfo;
import com.ccb.jyzx.expand.ouapi.service.OrganiztionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ccb.jyzx.expand.ouapi.view.request.IdRequest;

import java.util.List;

/**
 * @author XIEFEI
 * @date 2019-11-13 13:32
 * @Description 组织信息查询接口
 **/
@Controller
@RequestMapping("/ooapi/api/org")
@Api(tags = "组织机构信息相关接口")
public class OrganizationController {
    @Autowired
    OrganiztionService organiztionService;

    @ApiOperation(value = "根据id查询组织信息", notes = "根据id查询组织信息")
    @ResponseBody
    @PostMapping(value = "getById", consumes = "application/json;charset=UTF-8")
    public OrganiztionInfo getReport(@RequestBody IdRequest json) {
        return StringUtils.isNotBlank(json.getId()) ? organiztionService.getById(json.getId()) : new OrganiztionInfo();
    }

    @ApiOperation(value = "查询所有组织信息", notes = "查询所有组织信息")
    @ResponseBody
    @PostMapping(value = "getAll", consumes = "application/json;charset=UTF-8")
    public List<OrganiztionInfo> getAll() {
        return organiztionService.getAll();
    }
}
